package com.qyl.mainclass;

public class Car {
    //汽车基本信息
    private String name;
    private String color;

    //有参构造方法
    public Car(String name,String color){
        this.name = name;
        this.color = color;
    }

    //无参构造方法
    public Car(){
        this.name = null;
        this.color = null;
    }

    //汽车驾驶方法
    public void drive(){
        System.out.println( "一辆" + color + name + "正在行驶。");
    }

    //汽车按喇叭方法
    public void horn(){
        System.out.println( "一辆" + color + name + "正在按喇叭。");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}
